/**
Group: efl/timepicker/button (@since 1.23)
	 Part Text: efl.text (required)
	 Part Swallow: efl.background (required)
	 Part Swallow: efl.content (required)
	 Signal: efl,content,set
	 Signal: efl,content,unset
	 Signal: efl,state,animation,activated
	 Signal: efl,state,background,set
	 Signal: efl,state,background,unset
	 Signal: efl,state,disabled
	 Signal: efl,state,enabled
	 Signal: efl,text,set
	 Signal: efl,text,unset
Group: efl/timepicker (@since 1.23)
	 Part Swallow: efl.field0 (required)
	 Part Swallow: efl.field1 (required)
	 Part Swallow: efl.field2 (required)
	 Signal: efl,ampm,visible,off
	 Signal: efl,ampm,visible,on
	 Signal: efl,colon_field0,visible,off
	 Signal: efl,colon_field0,visible,on
	 Signal: efl,colon_field1,visible,off
	 Signal: efl,colon_field1,visible,on

*/
#define TP_24H 1
#define TP_HR 2
#define TP_MN 4
group { "efl/timepicker";
   data.item: "version" "123";
   script {
      public btmode;
      public eval_mode(m) {
         new v24h = m & TP_24H;
         new vhr  = m & TP_HR;
         new vmn  = m & TP_MN;
         if (v24h) {
            set_state(PART:"efl.field0", "default", 0.0);
            if (vhr) {
               set_state(PART:"efl.field1", "default", 0.0);
               if (vmn) {
                  set_state(PART:"efl.field2", "invisible", 0.0);
                  set_state(PART:"colon", "default", 0.0);
               } else {
                  set_state(PART:"efl.field2", "default", 0.0);
                  set_state(PART:"colon", "invisible", 0.0);
               }
            } else {
               set_state(PART:"efl.field1", "invisible", 0.0);
               if (vmn) {
                  set_state(PART:"efl.field2", "invisible", 0.0);
                  set_state(PART:"colon", "invisible", 0.0);
               } else {
                  set_state(PART:"efl.field2", "default", 0.0);
                  set_state(PART:"colon", "invisible", 0.0);
               }
            }
         } else {
            set_state(PART:"efl.field0", "invisible", 0.0);
            if (vhr) {
               set_state(PART:"efl.field1", "default", 0.0);
               if (vmn) {
                  set_state(PART:"efl.field2", "invisible", 0.0);
                  set_state(PART:"colon", "default", 0.0);
               } else {
                  set_state(PART:"efl.field2", "default", 0.0);
                  set_state(PART:"colon", "invisible", 0.0);
               }
            } else {
               set_state(PART:"efl.field1", "invisible", 0.0);
               if (vmn) {
                  set_state(PART:"efl.field2", "invisible", 0.0);
                  set_state(PART:"colon", "invisible", 0.0);
               } else {
                  set_state(PART:"efl.field2", "default", 0.0);
                  set_state(PART:"colon", "invisible", 0.0);
               }
            }
         }
      }
      flag_set(flag) {
         new m = get_int(btmode) | flag;
         set_int(btmode, m); eval_mode(m);
      }
      flag_unset(flag) {
         new m = get_int(btmode) & ~flag;
         set_int(btmode, m); eval_mode(m);
      }
   }
   parts {
      spacer { "base";
         scale;
         desc { "default";
            min: 81 77;
         }
         desc { "24h";
            min: 54 77;
         }
      }
      rect { "bg";
         desc { "default";
            rel.to: "base";
            color: 0 0 0 0; // no cc
         }
      }
      text { "colon";
         scale;
         desc { "default";
            rel1.to: "efl.field1";
            rel1.relative: 1.0 0.0;
            rel1.offset: 4 4;
            rel2.to: "efl.field2";
            rel2.relative: 0.0 1.0;
            rel2.offset: -5 -5;
            offscale;
            color_class: "/fg/normal/timepicker";
            text { font: FN; size: 10;
               min: 1 1;
               text: ":";
               align: 0.5 0.5;
            }
            vis;
            fixed: 1 1;
         }
         desc { "invisible";
            inherit: "default" 0.0;
            hid;
         }
      }
      swallow { "efl.field1"; required;
         scale;
         desc { "default";
            min: 23 69;
            rel1.offset: 4 4;
            rel2.offset: -5 -5;
            rel2.relative: (1/3) 1.0;
            offscale;
         }
         desc { "invisible";
            inherit: "default" 0.0;
            hid;
         }
      }
      swallow { "efl.field2"; required;
         scale;
         desc { "default";
            min: 23 69;
            rel1.offset: 4 4;
            rel1.relative: (1/3) 0.0;
            rel2.offset: -5 -5;
            rel2.relative: (2/3) 1.0;
            offscale;
         }
         desc { "invisible";
            inherit: "default" 0.0;
            hid;
         }
      }
      swallow { "efl.field0"; required;
         scale;
         desc { "default";
            min: 23 69;
            rel1.offset: 4 4;
            rel1.relative: (2/3) 0.0;
            rel2.offset: -5 -5;
            offscale;
         }
         desc { "invisible";
            inherit: "default" 0.0;
            hid;
         }
      }
      rect { "access";
         repeat;
         desc { "default";
            rel.to: "base";
            color: 0 0 0 0; // no cc
         }
      }
   }
   programs {
      program { signal: "efl,ampm,visible,on"; source: "efl";
         script { flag_unset(TP_24H); }
      }
      program { signal: "efl,ampm,visible,off"; source: "efl";
         script { flag_set(TP_24H); }
      }
      program { signal: "efl,colon_field0,visible,on"; source: "efl";
         script { flag_set(TP_HR); }
      }
      program { signal: "efl,colon_field0,visible,off"; source: "efl";
         script { flag_unset(TP_HR); }
      }
      program { signal: "efl,colon_field1,visible,on"; source: "efl";
         script { flag_set(TP_MN); }
      }
      program { signal: "efl,colon_field1,visible,off"; source: "efl";
         script { flag_unset(TP_MN); }
      }
   }
}

group { "efl/timepicker/button";
   inherit: "efl/button";
   data.item: "version" "123";
   parts {
      image { "base";
         desc { "default";
            min: 23 23;
            max: 23 23;
         }
         desc { "pressed";
            min: 23 23;
            max: 23 23;
         }
      }
   }
}
